package Day2025_03_04;

public class LeetCode1047 {
    public String removeDuplicates(String s) {
        int n = s.length();
        StringBuffer ret = new StringBuffer();
        for (int i = 0; i < n; i++) {
            if (ret.length() == 0 || ret.charAt(ret.length() - 1) != s.charAt(i)) ret.append(s.charAt(i));
            else ret.deleteCharAt(ret.length() - 1);
        }
        return ret.toString();
    }
}
